Completed
Push — master ( a0dc3e...1ff52f )
by Magnus
04:45
created

app.use   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 7

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 3
Bugs 0 Features 0
Metric Value
cc 1
c 3
b 0
f 0
nc 1
dl 0
loc 7
rs 9.4285
ccs 0
cts 4
cp 0
crap 2
nop 3
1
"use strict";
2
3
const express = require('express');
4
const routes = require('./routes');
5
const http = require('http');
6
const errorHandler = require('errorhandler');
7
const logger = require('morgan');
8
9
const app = express();
10
const server = http.createServer(app);
11
12 2
const dsn =  process.env.DBWEBB_DSN || "mongodb://localhost:27017/mumin";
13
14
const socket = require('./src/socket');
15
16
socket.socket(server);
17
18
// all environments
19 2
app.set('port', process.env.DBWEBB_PORT || 3000);
20
app.use(logger('dev'));
21
22
// development only
23 2
'development' == app.get('env') && app.use(errorHandler());
24
25
app.locals.something = 'value';
26
app.locals.qaz = 'qut';
27
28
app.get('/', routes.index);
29
app.get('/posts/:id', routes.posts);
30
app.get('/db/getAll', routes.dbGetAll);
31
app.get('/db/insert/:ob', routes.dbInsert);
32
33
34
app.use(function(req, res, next) {
35
    let err = new Error('Not Found');
36
37
    err.status = 404;
38
    next(err);
39
    res.json({'error': 'error'});
40
});
41
42
server.listen(app.get('port'), () => {
43
    console.info('Express server listening on port ' + app.get('port'));
44
    console.info('DNS is ' + dsn);
45
});
46
47
module.exports = app;
48